import java.lang.reflect.Field;

public class ReflectionTest {
    public static void main(String[] args) {
        try {
            // 创建Person类的实例
            Person person = new Person();

            // 获取Person类的Class对象
            Class<?> clazz = person.getClass();

            // 获取私有字段name的Field对象
            Field nameField = clazz.getDeclaredField("name");
            
            // 设置私有字段可访问
            nameField.setAccessible(true);

            // 读取私有字段name的值
            String name = (String) nameField.get(person);
            System.out.println("Original name: " + name);

            // 修改私有字段name的值
            nameField.set(person, "Jane Doe");
            System.out.println("Updated name: " + nameField.get(person));
        } catch (NoSuchFieldException | IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}